<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 函数返回表示“一杯绿茶（green tea）”的字符串
        const prepareTea = () => 'greenTea';

        /*
        有一个函数（代表茶的种类）和需要几杯茶，下面的函数返回一个数组，包含字符串（每个字符串表示一杯特别种类的茶）。
        */
        const getTea = (numOfCups) => {
            const teaCups = [];

            for (let cups = 1; cups <= numOfCups; cups += 1) {
                const teaCup = prepareTea();
                teaCups.push(teaCup);
            }
            // getTea方法 返回的是一个数组
            return teaCups;
        };

        const tea4TeamFCC = getTea(4);
        console.log(tea4TeamFCC); // 输出数组 ["greenTea", "greenTea", "greenTea", "greenTea"]
    </script>
</body>

</html>